﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Globalization;
using System.Data.SqlClient;
using System.Configuration;

public partial class LoginPage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
            SetYearDropDownValue();
    }
    private void SetYearDropDownValue()
    {
        PersianCalendar persianCalendar = new PersianCalendar();
        int currentYear = persianCalendar.GetYear(DateTime.Now);
        for (int i = 0; i <= 3; i++)
        {
            ListItem listItem = new ListItem();
            listItem.Value = listItem.Text = (currentYear - i).ToString();
            YearDropDownList.Items.Add(listItem);
        }
    }

    protected void LoginPatientClick(object sender, EventArgs e)
    {
        string year = GetYear();
        ///////if (LoginUser.IsSecurePatient(year, PhoneTextBox.Text, CodeTextBox.Text))
        /////////Response.Redirect(string.Format("{0}/{1}/{2}/_Patient", PhoneTextBox.Text, CodeTextBox.Text, year));        
        //Response.Redirect(string.Format("Patient/ShowToPatient.aspx?tel={0}&code={1}&year={2}", PhoneTextBox.Text, CodeTextBox.Text, year));
    }

    private string GetYear()
    {
        return YearDropDownList.SelectedValue.Substring(2, 2) + "/";
    }

    protected void LoginDoctorClick(object sender, EventArgs e)
    {

        PersianCalendar persianCalendar = new PersianCalendar();
        string year = persianCalendar.GetYear(DateTime.Now).ToString().Replace("13", "");
        year = "88";
        //Doctor => RoleId = 2
        //if (LoginUser.IsSecure(DoctorPassowrdTextBox.Text, DoctorUserNameTextBox.Text, year, 2))
        /////////Response.Redirect(string.Format("{0}/{1}/_Doctor", DoctorUserNameTextBox.Text, year));      
        Response.Redirect(string.Format("Doctor/ShowToDoctor.aspx?username={0}&year={1}", DoctorUserNameTextBox.Text, year));
    }
}